$(document).ready(function() {
        $(".yuan").bind("change", function() {
                var val = $(this).val();
                $.ajax({
                        type: "post",
                        url: "/public/ajaxGetChildZone",
                        data: "id=" + val + "&randomNum=" + Math.random(),
                        dataType: "html",
                        success: function(data) {
                                var html = "";
                                if (val === '1')
                                        html += "<option value='0'>省份</option>";
                                else
                                        html += "<option value='0'>大洲</option>";
                                html += data;
                                $("#slcProvice").html(html);
                                if (val === '1') {
                                        $("#slcCity").html("<option value='0'>城市</option>");
                                } else {
                                        $("#slcCity").html("<option value='0'>国家</option>");
                                }
                        },
                        error: function() {
                                //alert("网络传输错误，请稍后再试");
                        }
                });
        });
        $(".yuan").eq(0).change();

        $("#slcProvice").bind("change", function() {
                $.ajax({
                        type: "post",
                        url: "/public/ajaxGetChildZone",
                        data: "id=" + $(this).val() + "&randomNum=" + Math.random(),
                        success: function(data) {
                                var html = "";
                                var t = $("input[name='country']:checked").val();
                                if (t == "1") {
                                        html += "<option value='0'>城市</option>";
                                } else {
                                        html += "<option value='0'>国家</option>";
                                }
                                html += data;
                                $("#slcCity").html(html);
                        },
                        error: function() {
                                alert("网络传输错误，请稍后再试");
                        }
                });
        });

        $("#txtDes").bind("keydown", function(e) {
                var count = 2000 - $(this).val().length;
                if (count > 0)
                        $("#i_count").html("您还可以输入" + count + "个字");
                else
                        e.preventDefault();
        });

});
//问题提交验证
function Validate() {
        var title = $("#txtTitle").val();
        var country = $(".yuan:checked").val();
        var provice = $("#slcProvice").val();
        var city = $("#slcCity").val();
        var yzm = $("#txt_yzm").val();
        var content = $("#txtDes").val();
        if (content.length < 10) {
                alert('提问内容不能少于10个字!');
                return false;
        }
        if (title.length < 2 || title.length > 50) {
                alert('请正确填写标题');
                return false;
        } else if (provice == "0") {
                alert('请选择省份或大洲');
                return false;
        } else if (country == "2" && city == "0") {
                alert('请选择国家');
                return false;
        } else if (!yzm) {
                alert('请输入验证码');
                return false;
        }

        return true;
}
//搜索提交表单
function submitsearchform() {
        var form = $("#mySearch");
        form.submit();
}
